<template>
  <div>
    <!-- 上方搜索栏 -->
    <div class="ty_search">
      <el-form :inline="true" :model="formInline" label-width="90px">
        <el-form-item label="关键词" size="mini">
          <el-input
            v-model="formInline.user"
            placeholder="搜索用户名/姓名/手机号"
          ></el-input>
        </el-form-item>

        <el-form-item label="人员类型" size="mini">
          <el-select v-model="formInline.TYPE2" placeholder="请选择人员类型">
            <el-option label="是" value="7"></el-option>
            <el-option label="否" value="8"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="审核状态" size="mini">
          <el-select v-model="formInline.TYPE2" placeholder="请选择审核状态">
            <el-option label="待审核" value="7"></el-option>
            <el-option label="已通过" value="8"></el-option>
            <el-option label="已拒绝" value="9"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="注册时间" size="mini">
          <el-date-picker
            v-model="formInline.value"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item size="mini">
          <el-button
            type="primary"
            @click="onSubmit(formInline)"
            icon="el-icon-search"
            >查询</el-button
          >
          <el-button @click="cancel" icon="el-icon-refresh-right"
            >清空</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <el-card>
      <!-- 表格上方按钮 -->
      <div style="margin-bottom: 10px">
        <el-button type="primary" size="mini" @click="add" icon="el-icon-plus"
          >新 增</el-button
        >
        <el-button size="mini" type="success" icon="el-icon-check"
          >批量审核</el-button
        >
      </div>
      <el-table
        border
        ref="multipleTable"
        :data="tableData"
        style="width: 100%"
        height="40vh"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column type="index" width="50" label="序号">
        </el-table-column>
        <el-table-column prop="NAME" label="用户名"></el-table-column>
        <el-table-column prop="NAME" label="人员类型"></el-table-column>
        <el-table-column prop="NAME" label="姓名"></el-table-column>
        <el-table-column prop="NAME" label="手机号"></el-table-column>
        <el-table-column prop="NAME" label="所属单位"></el-table-column>
        <el-table-column prop="NAME" label="注册时间"></el-table-column>
        <el-table-column prop="NAME" label="审核状态" width="100">
          <template slot-scope="scope">
            <div :class="setClass(scope.row.status)">
              {{ setName(scope.row.status) }}
            </div>
          </template>
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="200">
          <template slot-scope="scope">
            <el-button type="text" size="small" @click="check">查看</el-button>
            <el-button type="text" size="small">编辑</el-button>
            <el-button type="text" size="small" @click="toExamine(scope.row)"
              >审核</el-button
            >
            <el-button type="text" size="small">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <MyPagination
        :pagination="pagination"
        @current-change="pageChange"
        @size-change="sizeChange"
      ></MyPagination>

      <Form ref="form" />
      <ToExamine ref="toExamine" />
      <Formcheck ref="formCheck" />
    </el-card>
  </div>
</template>
<script>
import MyPagination from "@/components/common/pagination.vue";
import Form from "./form.vue";
import Formcheck from "./check.vue";
import ToExamine from "./toExamine.vue";
export default {
  components: {
    MyPagination,
    Form,
    ToExamine,
    Formcheck
  },
  data() {
    return {
      tableData: [
        {
          NAME: "测试数据",
          status: "0",
        },
        {
          NAME: "测试数据",
          status: "1",
        },
        {
          NAME: "测试数据",
          status: "2",
        },
      ],
      pagination: {
        limit: 20,
        page: 1,
        total: 100,
      },
      formInline: {
        user: "",
        TYPE: "",
        TYPE2: "",
        value: "",
      },
      multipleSelection: [],
      options: [
        {
          value: "zhinan",
          label: "指南",
          children: [
            {
              value: "shejiyuanze",
              label: "设计原则",
            },
            {
              value: "yizhi",
              label: "一致",
            },
            {
              value: "fankui",
              label: "反馈",
            },
            {
              value: "xiaolv",
              label: "效率",
            },
            {
              value: "kekong",
              label: "可控",
            },
          ],
        },
      ],
    };
  },
  created() {
    // this.onSubmit(this.formInline);
  },
  methods: {
    add() {
      this.$refs.form.isShow();
    },
    check(){
      this.$refs.formCheck.isShow();
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    toExamine(data) {
      this.$refs.toExamine.isShow();
    },
    onSubmit(formInline) {
      plstutatuscfApproveInfo({
        page: this.pagination.page,
        limit: this.pagination.limit,
        TYPE: this.formInline.TYPE,
        search: this.formInline.user,
      }).then((res) => {
        this.tableData = res.body;
      });
    },
    setClass(data) {
      switch (data) {
        case "0":
          return "status yellow";
          break;
        case "1":
          return "status green";
          break;
        case "2":
          return "status red";
          break;
      }
    },
    setName(data) {
      switch (data) {
        case "0":
          return "待审核";
          break;
        case "1":
          return "已通过";
          break;
        case "2":
          return "已拒绝";
          break;
      }
    },
    cancel() {},
    pageChange(val) {
      this.pagination.page = val;
      this.onSubmit(this.formInline);
    },
    sizeChange(val) {
      this.pagination.limit = val;
      this.onSubmit(this.formInline);
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep .el-card__body {
  height: 100%;

  width: 100%;
}
.status {
  padding: 4px 0px;
  border-radius: 4px;
  text-align: center;
  font-family: PingFangSC, PingFang SC;
  &.yellow {
    color: #ff8000;
    background: #fff7ec;
    border: 1px solid rgba(255, 153, 0, 0.2);
  }
  &.red {
    color: #ff2020;
    background: #fff1f0;
    border: 1px solid rgba(245, 22, 4, 0.2);
  }
  &.green {
    color: #19ba24;
    background: #f5fff2;
    border: 1px solid rgba(25, 186, 36, 0.5);
  }
}
</style>
